home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 3 / Test / Main.cpp next >
Encoding:
C/C++ Source or Header  |  2004-05-20  |  1.8 KB  |  51 lines

  1. //-----------------------------------------------------------------------------
  2. // System Includes
  3. //-----------------------------------------------------------------------------
  4. #include <windows.h>
  5.  
  6. //-----------------------------------------------------------------------------
  7. // Engine Includes
  8. //-----------------------------------------------------------------------------
  9. #include "..\Engine\Engine.h"
  10.  
  11. //-----------------------------------------------------------------------------
  12. // Test State Class
  13. //-----------------------------------------------------------------------------
  14. class TestState : public State
  15. {
  16.     //-------------------------------------------------------------------------
  17.     // Update function for the TestState.
  18.     //-------------------------------------------------------------------------
  19.     virtual void Update( float elapsed )
  20.     {
  21.         // Check if the user wants to exit.
  22.         if( g_engine->GetInput()->GetKeyPress( DIK_Q ) )
  23.             PostQuitMessage( 0 );
  24.     };
  25. };
  26.  
  27. //-----------------------------------------------------------------------------
  28. // Application specific state setup.
  29. //-----------------------------------------------------------------------------
  30. void StateSetup()
  31. {
  32.     g_engine->AddState( new TestState, true );
  33. }
  34.  
  35. //-----------------------------------------------------------------------------
  36. // Entry point for the application.
  37. //-----------------------------------------------------------------------------
  38. int WINAPI WinMain( HINSTANCE instance, HINSTANCE prev, LPSTR cmdLine, int cmdShow )
  39. {
  40.     // Create the engine setup structure.
  41.     EngineSetup setup;
  42.     setup.instance = instance;
  43.     setup.name = "Engine Control Test";
  44.     setup.StateSetup = StateSetup;
  45.  
  46.     // Create the engine (using the setup structure), then run it.
  47.     new Engine( &setup );
  48.     g_engine->Run();
  49.  
  50.     return true;
  51. }